package dao;

import java.sql.*;

public class BaseDao {

    public final static String driver = "com.mysql.jdbc.Driver";                     // 数据库驱动
    public final static String url    = "jdbc:mysql://localhost:3306/bookmarkdb";   // url
    public final static String dbName = "root";        // 数据库用户名
    public final static String dbPass = "1234";       // 数据库密码

    public Connection getConn()
    {
        Connection conn = null;
        try {
            Class.forName(driver);
            conn = DriverManager.getConnection(url,dbName,dbPass);
        } catch (Exception e) {
            // TODO: handle exception
        }
        return conn;
    }

    public void closeAll(Connection conn,Statement stmt,ResultSet rs)
    {
        try {
            if (rs!=null) {
                rs.close();
            }
            if (stmt!=null) {
                stmt.close();
            }
            if (conn!=null) {
                conn.close();
            }
        } catch (Exception e) {
            // TODO: handle exception
        }
    }
}

